package com.diqizu.servlet;

import java.io.IOException;

import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.diqizu.entity.DesignerEntity;

/**
 * Servlet implementation class Designeridea
 */

import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.diqizu.dao.SheJiDao;
import com.diqizu.entity.IntroDuctionEntity;
import com.diqizu.entity.MessaGeEntity;
import com.diqizu.utli.Result;
import com.diqizu.entity.DesignerEntity;

/**
 * Servlet implementation class Designeridea
 */
@WebServlet("/Designeridea")
public class Designeridea extends BaseServlet {
  SheJiDao dao = new SheJiDao();

  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    ArrayList<DesignerEntity> desingner = dao.designer();
    ArrayList<IntroDuctionEntity> introduce = dao.Introduction();
    request.setAttribute("desingner", desingner);
    request.setAttribute("Introduce", introduce);
    System.out.println(desingner);
    request.getRequestDispatcher("about.jsp").forward(request, response);

  }
  public void getin(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String Content = request.getParameter("Content");
    String Content2 = request.getParameter("Content2");
    String gourl = request.getParameter("gourl");
    String Content3 = request.getParameter("Content3");
    String Content4 = request.getParameter("Content4");
    String gourl2 = request.getParameter("gourl2");
    
    boolean res = dao.addIntroduction(new IntroDuctionEntity(1000, Content,Content2,gourl, Content3, Content4,gourl));
    if (res == true) {
      response.sendRedirect("BannerList.jsp");

    }
  }
  public void getmessage(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String name = request.getParameter("name");
    String Telephone = request.getParameter("telephone");
    String email = request.getParameter("email");
    String contentt = request.getParameter("contentt");
    String text = request.getParameter("text");
    boolean res = dao.addmessage(new MessaGeEntity(1000, name,Telephone, email, contentt,text));
    PrintWriter out = response.getWriter();
    if (res) {
      out.write(Result.toClient(0, "添加成功"));
    } else {
      out.write(Result.toClient(1, "添加失败"));
    }

    out.flush();
    out.close();

  }
}
